package android.framework.binding.converters;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.framework.rpc.convertor.ConvertorException;

public class ConverterDateString implements IConverter<Date, String>{
	private SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
	
	public String convertTo(Date value) {
		return format.format(value);
	}

	public Date convertFrom(String value) {
		try {
			return format.parse(value);
		} catch (ParseException e) {
			throw new ConvertorException("can't parse " + value, e);
		}
	}

}
